{% extends "base_site.html" %}
{% load cmdb_extras %}

{% block content %}
<!--<link rel="stylesheet" type="text/css" href="/media/css/forms.css" /> -->
<link rel="stylesheet" type="text/css" href="/media/css/forms.css" />
<script type="text/javascript" src="/admin/jsi18n/"></script>
<script type="text/javascript" src="/media/js/core.js"></script>
<script type="text/javascript" src="/media/js/calendar.js"></script>
<script type="text/javascript" src="/media/js/admin/DateTimeShortcuts.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript" src="/media/js/jquery.min.js"></script>
<script type="text/javascript" src="/media/js/jquery.init.js"></script> 
<script type="text/javascript" src="/media/js/actions.min.js"></script>
<script type="text/javascript" src="/media/js/TableSort.js"></script>
<script type="text/javascript">
$(function(){
	$("#tb").sorttable({
		ascImgUrl: "/media/img/bullet_arrow_up.png",
		descImgUrl: "/media/img/bullet_arrow_down.png",
		ascImgSize: "8px",
		descImgSize: "8px",
		allowMask:false,
		onSorted: function (cell) {
			$("#tb").find("tr").removeClass("row1");
			$("#tb").find("tr:odd").addClass("row1");
		}
	});
});
</script>


<fieldset class="module aligned ">
	<div class="form-row title"> 
	    <div>
		<form action="" method="GET" >
			<h>ip: <input type="text" name="ip" value="{{ ip }}" >
			server name: <input type="text" name="name" value="{{ name }}" >
			physical ip: <input type="text" name="pip" value="{{ pip }}" ></h><br/>
			<h>system: 
			<select name="system" >
				<option value="" {% if system == "" %}selected="selected"{% endif %} >All</option>
				<option value="W" {% if system == "W" %}selected="selected"{% endif %} >Windows</option>
				<option value="L" {% if system == "L" %}selected="selected"{% endif %} >Linux</option>
				<option value="V" {% if system == "V" %}selected="selected"{% endif %} >VMware</option>
			</select>

			IDC: 
			<select name="idc" >
				<option value="" {% if idc == "" %}selected="selected"{% endif %} >All</option>
				{% for i in idcs %}
				<option value="{{ i.name }}" {% if idc == i.name  %}selected="selected"{% endif %} >{{ i.name }}</option>
				{% endfor %}
			</select>

			project:
			<select name="project" >
				<option value="" {% if project == "" %}selected="selected"{% endif %} >All</option>
				{% for p in projects %}
				<option value="{{ p.name }}" {% if project == p.name %}selected="selected"{% endif %} >{{ p.name }}</option>
				{% endfor %}
			</select>

			is physical server:
			<select name="ispserver" >
				<option value="" {% if ispserver == "" %}selected="selected"{% endif %} >All</option>
				<option value="Y" {% if ispserver == "Y" %}selected="selected"{% endif %} >Yes</option>
				<option value="N" {% if ispserver == "N" %}selected="selected"{% endif %} >No</option>
			</select>

			funtion:
			<select name="funtion" >
				<option value="" {% if funtion == "" %}selected="selected"{% endif %} >All</option>
				<option value="1" {% if funtion == "1" %}selected="selected"{% endif %} >Monet</option>
				<option value="2" {% if funtion == "2" %}selected="selected"{% endif %} >APP</option>
				<option value="3" {% if funtion == "3" %}selected="selected"{% endif %} >DB</option>
				<option value="4" {% if funtion == "4" %}selected="selected"{% endif %} >VMware</option>
			</select>
			created on:
			<input name="created_on" value="{{ created_on }}" class="vDateField" type="text" id="id_date" size="11"><span class="datetimeshortcuts"></span>
			&nbsp;&nbsp;&nbsp;
		    <input type="submit" value = "Show Data" /></h><br/>
		</form>
		</div>
		</div>
	</fieldset>
	<style>
	th {width:100px;}
	</style>
	<h2>servers:</h2>
	<table id="tb">
		<tr style="background:#f7f89a" role="head" ><th sort="true" style="width:30px" >sn</th><th sort="true">ip</th><th sort="true" style="width:150px" >server name</th><th sort="true" >IDC</th><th sort="true" >project</th><th sort="true" style="width:120px" >physical_server</th><th sort="true" >physical ip</th><th sort="true"  style="width:50px" >core</th><th sort="true"  style="width:50px" >ram</th><th sort="true" >hard disk</th><th sort="true" >system</th><th sort="true" >function</th><th sort="true" style="width:150px" >created on</th></tr>
		{% for s in servers %}
		{% if forloop.counter0|tr_color %}
		<tr class="row1">
		{% else %}
		<tr>
		{% endif %}
			<td>{{ forloop.counter }}</td>
			<td><a href="/cmdb/services/?ip={{ s.ip }}">{{s.ip}}</a></td><td>{{ s.name }}</td><td>{{ s.idc }}</td><td>{{ s|showProjects }}</td>
			<td>
			{% if s.physical_server == "Y" %}
			Yes
			{% else %}
			No
			{% endif %}
			</td>
			<td>{{ s.physical_server_ip }}</td><td>{{ s.core }}</td><td>{{ s.ram }}</td><td>{{ s.hard_disk }}</td>
			<td>
			{% if s.server_type == "W" %}
			Windows
			{% else %}
			{%if s.server_type == "L" %}
			Linux
                        {%else%}
			VMware
			{% endif %}
			{% endif %}
			</td>
			<td>
			{{s.server_function|showFunction}}
			</td>
			<td>{{ s.created_on|date:"Y-m-d H:i" }}</td>
		</tr>
		{% endfor %}
	</table>

{% endblock %}
